cc.Class({
    extends: cc.Component,

    properties: {
        prefabLevelItem: cc.Prefab,
        labelLevelName: cc.Label,
        levelItemcontent: cc.Node,
    },
    
    // start() {
    //     this._labelLevelName = this.node.getChildByName("txt_levelname");
    //     this._levelItemcontent = this.node.getChildByName("img_levelitem_content");
    // },
    /**
     * 创建时使用
     * @param {} data 
     */
    setLevelData(data) {
        if (data) {
            this.labelLevelName.string = data[0].gameScene;
            
            var level = window.gameConfig.gameData.level;//关卡
            cc.log("当前第几关"+level);
            for (let index = 0; index < 5; index++) {
                 //小于当前闯关数就显示关卡否则就是背景
                 let isShowLevelNumber = data[index].level <= level;
                 var objLevleItem = cc.instantiate(this.prefabLevelItem);
                 let objLevleItemCom = objLevleItem.getComponent("LevelItem");
                 objLevleItemCom.setListItemInfo(data[index], index);
                 objLevleItemCom.setIsShowLevelNumber(isShowLevelNumber);
                 this.levelItemcontent.addChild(objLevleItem);
            }
        } else {
            cc.log("无关卡数据");
        }
    },
    /**
     * 更新关卡数据
     */
    updateLevelData(data,number){

    }

});